package com.rongmai.web.bo;

import com.rongmai.db.mapper.SubmitProductAuditMapper;
import com.rongmai.db.model.SubmitProductAudit;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

@Slf4j
@Service
public class SubmitProductBo {

    @Resource
    private SubmitProductAuditMapper submitProductAuditMapper;

    public void add(SubmitProductAudit submitProduct) {
        submitProduct.setCreateTime(new Date());
        submitProductAuditMapper.insert(submitProduct);
    }

    public void edit(SubmitProductAudit param) {
        SubmitProductAudit SubmitProductAudit = get(Long.valueOf(param.getId()));
        BeanUtils.copyProperties(param, SubmitProductAudit);
        submitProductAuditMapper.updateByPrimaryKeySelective(SubmitProductAudit);
    }

    public SubmitProductAudit get(Long id) {
        return submitProductAuditMapper.selectByPrimaryKey(id);
    }

    public void delete(Long id) {
        submitProductAuditMapper.deleteByPrimaryKey(id);
    }
}
